﻿<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Strict//EN">
<html>
<head>
<meta http-equiv="Content-Language" content="en-us">
<title>GTK</title>
<link rel="stylesheet" type="text/css" href="../../style.css">
<style type="text/css">
.style1 {
	font-size: large;
}
</style>
</head>
<body>

<h2>GTK System Driver<span class="style1"> (since 3.0)</span></h2>
<p>This driver was designed for the GTK+ 
  version 2 and 3. It can be compiled in Windows or UNIX.</p>
<p>Although GTK has layout elements they are not used. IUP fill, vbox, hbox and 
zbox containers are implemented independent from the native system.</p>
<p>The oldest GTK version that can be used is 2.4, oldest versions will not 
compile. But using versions older than 2.12 several features will not work. 
Critical features need at least version 2.8.</p>
<p>Currently it is not available for IRIX, AIX and SunOS. But is it available 
for SunOS10 and it is not available for Linux24.</p>
<h3>Tips</h3>
<h4>Locale</h4>
<p>Since 3.28, in IupOpen we call setlocale(LC_NUMERIC, "C") to reset the locale 
to the default for C applications. Because GTK is changing the locale in 
gtk_init to match the system language, and this affects the parse of the decimal 
separator of floating point numbers in strings.</p>
<h4>Inspecting Native Controls</h4>
<p>The <strong>GTK+ Inspector</strong> tool included in GTK is very useful to 
inspect GTK controls position, size and visibility. To enable the GTK+ 
inspector, you can use the Control-Shift-I or Control-Shift-D keyboard 
shortcuts, or set the GTK_DEBUG=interactive&nbsp;environment variable. In a similar 
way you can also use the <a href="../dlg/iuplayoutdialog.html">IupLayoutDialog</a> 
to show IUP controls attributes and callbacks, in a interactive display of the 
dialog layout.</p>
<h4>GTK 3.x (since 3.7)</h4>
<p>GTK 3.x is supported. But the pre-compiled binaries, up to Linux 3.2, are still built with GTK 
2.x. This is because GTK 3 involves a big change for drawing applications, and 
most Tecgraf applications are heavily graphics dependent. The main change is 
that GDK does not have drawing primitives anymore, and all drawing is performed 
by Cairo. Cairo does not have support for XOR used by many drawing applications 
to perform a selection rubber band. Also Cairo could have a different behavior 
for some primitives. </p>
<p>Since Linux 3.13 the default is to use GTK 3.</p>
<p>For older Linux to build the driver with GTK 3.x support define USE_GTK3=Yes before calling 
make in the &quot;iup/src&quot; folder. Just the main library must be rebuilt. Also, if CD 
is used, the CD main library must be rebuilt with the same parameter.</p>
<h4>Dependencies</h4>
<p>GTK is in fact composed of several libraries. The GTK package contains the 
GDK library and depends on the ATK, Cairo, Glib and Pango libraries.</p>
<h4>X11 Dependencies (since 3.25)</h4>
<p>When using GTK 3, the X11 usage is drastically reduced. It is not necessary 
at all, although it is still there for backward compatibility. To completely 
remove the X11 dependencies define GDK_NULL in "iup/src/config.mak". The 
GDK_NULL definition can also be used for GTK 2, but there is a limitation, the 
SCREENSIZE attribute will not correctly exclude the desktop 
decorations.</p>
<h4>UTF-8</h4>
<p>GTK uses UTF-8 as its charset for all displayed text, so IUP will 
automatically convert all strings to (SetAttribute) and from (GetAttribute) 
UTF-8. But the default is still to use the current locale. To use UTF-8 strings set the global attribute UTF8MODE to YES.</p>

<h4>Windows</h4>

<p>The GTK driver can be compiled and used in Windows, but it is not recommended since it is slower and 
much more memory 
  consuming than the IUP native Windows driver.</p>
<p>When using DLLs in Windows, the &quot;iup.dll&quot; uses the Win32 driver. So 
applications that dynamically load IUP will always use the &quot;iup.dll&quot;, for 
example Lua using require. To use the IUP GTK dll in Windows you must rename the 
&quot;iupgtk.dll&quot; to &quot;iup.dll&quot;, so the GTK driver will be loaded instead of the Win32 
driver.</p>
<p>After installing the GTK binaries, we recommend changing the default theme 
to the &quot;MS-Windows&quot; theme. Edit the &quot;gtk\etc\gtk-2.0\gtkrc&quot; file and change its 
contents to:</p>
<pre>gtk-theme-name = &quot;MS-Windows&quot;</pre>
<h4>Ubuntu Unity</h4>
<p>Since Ubuntu version 11, there is a new desktop called&nbsp;Unity. This 
desktop introduces some changes that affect all applications. Two of these 
changes directly affect IUP applications.</p>
<p><strong>First</strong> the global menu forces all dialog menus to be displayed in the top of 
the desktop, like in MacOSX. This affected the size of the IUP dialog, it is 
fixed since IUP version 3.6. If you don&#39;t like the global menu you can remove it 
using:</p>
<pre style="border-color: inherit; vertical-align: baseline; outline: none; font-variant: normal; orphans: 2; text-align: start; text-indent: 0px; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;">sudo apt-get remove appmenu-gtk3 appmenu-gtk appmenu-qt</pre>
<p>You can also control that using &quot;export UBUNTU_MENUPROXY=0&quot;. There are other 
forms to control this feature - see &quot;<a href="http://www.webupd8.org/2011/03/disable-appmenu-global-menu-in-ubuntu.html" target="_blank">How 
to Disable the AppMenu</a>&quot;.</p>
<p style="border-color: inherit; vertical-align: baseline; outline: none; font-variant: normal; orphans: 2; text-align: start; text-indent: 0px; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;">In later Ubuntu versions you can do the command:</p>
<pre style="border-color: inherit; vertical-align: baseline; outline: none; font-variant: normal; orphans: 2; text-align: start; text-indent: 0px; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;">gsettings set com.canonical.Unity integrated-menus true </pre>
<p>or you can uninstall the "<a href="https://launchpad.net/ubuntu/+source/indicator-appmenu">indicator-appmenu</a>" 
package. See "<a href="https://askubuntu.com/questions/10481/how-do-i-enable-or-disable-the-global-application-menu">How 
do I enable or disable the global application menu?</a>".</p>
<p>In some systems when using the appmenu, the application menu items do not get 
inactive when set. </p>
<p><strong>Second</strong>, the scrollbars are reduced to a very tiny line and handlers are 
displayed only when the mouse moves over the right or bottom side of the 
element. All the controls, except the <strong>IupCanvas</strong>, will work ok with 
the new scrollbar. But in <strong>IupCanvas</strong> the SCROLL_CB callback will 
receive only the IUP_SBPOSV and IUP_SBPOSH operations codes (fixed in IUP 3.11.1).</p>
<p>You can remove the new scrollbar at the
<strong>Synaptic Package Manager</strong> or at the <strong>Ubuntu Software 
Center</strong> searching for &quot;overlay-scrollbar&quot; and removing the installed 
packages. You can also control that using "export LIBOVERLAY_SCROLLBAR=0". In later Ubuntu versions you can do the command:</p>
<pre>gsettings set com.canonical.desktop.interface scrollbar-mode normal  </pre>
<h4>MacOSX-Quartz</h4>
<p>The GTK driver also compiles in MacOSX with the new GTK port available at
<a href="http://gtk-osx.sourceforge.net/">http://gtk-osx.sourceforge.net/</a> 
using Quartz. 
But the <strong>IupGLCanvas</strong> is not available yet. You must use the GDK base driver of 
the CD library. Some elements like <strong>IupTree</strong> are not 100% functional 
because of the gtk-osx implementation. The 
installation of gtk-osx is quite complex because there are no pre-compiled 
binaries. Also if the MacOSX theme is used, several controls have problems. We 
hope that this will improve in the future. Must define GTK_MAC before compiling to enable this build.</p>
<h4>MacOSX-X11</h4>
<p>So for now we are distributing binaries that use the X11 version of GTK 2.16. 
They were installed using <a href="http://www.finkproject.org/">Fink</a>. Here 
is a simple guide to install fink so the pre-compiled binaries will work (tested 
in 10.5 and 10.6):</p>
<pre>Download latest fink source: <a href="http://downloads.sourceforge.net/fink/fink-0.29.21.tar.gz">fink-0.29.21</a>
tar -xvzf fink-0.29.21.tar.gz 
cd fink-0.29.21
./bootstrap
	Use all default answers, except for the second question about 64bits:
	(10.5) =&gt; (1) Default (mostly 32bit)  [because gcc use 32bit as default]
	(10.6) =&gt; (2) 64bit-only              [because gcc use 64bit as default]
/sw/bin/pathsetup.sh
fink selfupdate-rsync
fink index -f
fink install gtk+2 gtk+2-dev</pre>
<p>It will take some time to download and install everything, so have patience.</p>
<p>After that you should get something like this:</p>
<pre>fink --version
  Package manager version: 0.29.10
  Distribution version: selfupdate-rsync Thu Apr 29 11:51:11 2010, 10.6, x86_64  (10.6)
  Distribution version: selfupdate-rsync Thu Apr 29 11:50:49 2010, 10.5, i386    (10.5)

fink list -i gtk+2
  Information about XXXX packages read in X seconds.
   i   gtk+2            2.16.6-3     The Gimp Toolkit
   i   gtk+2-dev        2.16.6-3     The Gimp Toolkit
   i   gtk+2-shlibs     2.16.6-3     The Gimp Toolkit
</pre>

<p>You can use <a href="http://www.macports.org/">MacPorts</a> instead of Fink. 
The installation is very similar, but it seems simpler. Although we did not have 
the opportunity to test it, some users report that this work ok.</p>
<p>MacPorts have two GTK installations, one for X11 and one for Quartz. This is 
a lot simpler than trying to install the gtk-osx distribution. Just keep in mind 
that if using Quartz, OpenGL with IUP will not be available.</p>
<p>When building IUP or CD in MacOSX, define the following variables in the 
system before typing &quot;make&quot;:</p>
<pre>export USE_MACOS_OPENGL=Yes      # To use the OpenGL framework
export GTK_BASE=/sw              # For Fink
export GTK_BASE=/opt/local       # For MacPorts
export GTK_MAC=Yes               # For Quartz instead of X11</pre>

<h4>Native Code</h4>
<p>The GTK driver is not pure GTK and GDK code. It uses Win32 and X11 calls in 
some parts, specifically in "iupgtk_open.c". And it depends on some Win32 and 
X11 modules, such as: "iup*_info.c", "iup_glcanvas*.c". Also the CD library has 
some native code in the "cdcaironative_gdk.c" that affects the CD_IUP driver. 
These are the files that need to be changed for a fully functional <strong>MacOSX-Quartz</strong> 
driver. </p>

</body>

</html>
